package org.example.rmsmsapi.controller;


import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

/**
 * 测试控制器，演示请求和响应日志记录
 */
@RestController
@RequestMapping("/api/auth")
public class LogController {

    /**
     * 简单的GET请求示例
     * @param name 可选的名称参数
     * @return 包含问候语的Map
     */
    @GetMapping ("/GetYbpaInfo")
    public Map<String, String> hello(@RequestParam(required = false) String name) {
        Map<String, String> result = new HashMap<>();
        result.put("message", "Hello, " + (name != null ? name : "World"));
        return result;
    }

    /**
     * 带请求体的POST请求示例
     * @param data 请求数据
     * @return 包含处理结果的Map
     */
    @PostMapping("/process")
    public Map<String, Object> process(@RequestBody Map<String, Object> data) {
        Map<String, Object> result = new HashMap<>();
        result.put("status", "success");
        result.put("data", data);
        result.put("timestamp", System.currentTimeMillis());
        return result;
    }

    /**
     * 异常测试接口
     * @throws Exception 抛出异常
     */
    @GetMapping("/error")
    public void throwError() throws Exception {
        throw new RuntimeException("测试异常日志");
    }
}
    